/* Store the Tree Elements */
//typedef struct
//{
//	HuffmanTree *zeroChild;
//	HuffmanTree *oneChild;
//	unsigned short int	value; 		/* Value read from File */
//	unsigned short int	frequency;	/* Frequency of the Value */

//}HuffmanTree;

/* Linked List to Store the List of "Trees" That Still Need to be Merged Together */
typedef struct huff
{
	struct huff *nextItem;
	unsigned short int	value; 		/* Value read from File */
	unsigned short int	frequency;	/* Frequency of the Value */
	struct huff *zeroChild;
	struct huff *oneChild;
	char end_of;
	char dad;
}HuffmanList;

typedef struct
{
	unsigned short int value;
	char* code;
}HuffmanTable;

typedef struct
{
	char nchannels;
	char deep;//Numero de bits utilizado na codificacao
	unsigned short int nelem;//numero de elementos da tabela
	char eof[32];//codigo do elemento de end of file
}HuffmanHeader;

HuffmanList *busca( HuffmanList *lista, HuffmanList *elem);
HuffmanList *busca_imed_menor( HuffmanList *lista, unsigned short int frequencia);
void remover( HuffmanList **elem_anterior);
HuffmanList *criar_elem(unsigned short int valor);
void descomprimir_huffman();
void codificacao_huffman();
void remover_primeiro ( HuffmanList **lista);
void inserir( HuffmanList **lista,  HuffmanList *elem);
void comprimir_huffman(char *input, char *output );
void criar_arvore_huffmann( HuffmanList **lista);
void criar_tabela(HuffmanList *arvore, HuffmanTable *tabela, int *i, int nelem, char *acabou);
void ordenar_tabela(HuffmanTable *tabela, int nelem);
unsigned short int* TableToBit(short int deep, int NoE, HuffmanTable *table);
unsigned char* PuttingBitsTogetherTable(unsigned short int* dataBits, short int deep, int NoE, int *dataTogetherSize);
unsigned short int* FileToBit(short int deep, int NoE, unsigned short int *codeArray);
unsigned char* PuttingBitsTogetherFile(unsigned short int* dataBits, short int deep, int NoE, int *dataTogetherSize);
void escrever_huffmann (HuffmanHeader cabecalho, unsigned char *dados, int tam_dados, char *nome_arquivo);

